﻿using MediatR;
using U.B.DoMain;
using U.B.ErrorCode;
using U.B.ReadApi.Command;
using U.B.Repistory;

namespace U.B.ReadApi.CommandHander
{
    public class ReverseMenuCommandHander : IRequestHandler<ReverseMenuCommand, ApiResult<Menu>>
    {
        public readonly IRepistory<Menu> _menuRepistory;
        public ReverseMenuCommandHander(IRepistory<Menu> menuRepistory)
        {
            _menuRepistory = menuRepistory;
        }
        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<ApiResult<Menu>> Handle(ReverseMenuCommand request, CancellationToken cancellationToken)
        {
           ApiResult<Menu> result = new ApiResult<Menu>();
            result.code = Renum.显示成功;
            result.Message = Renum.显示成功.ToString();
            var meun = await _menuRepistory.GetModel(request.MenuId);
            result.Data = meun;
            return await Task.FromResult(result);
        }
    }
}
